﻿''' <summary>
''' 
''' </summary>
''' <remarks></remarks>
Public Class jointureBDD

    Protected _leftTraitement As Traitement
    Protected _rightTraitement As Traitement
    Protected _lLeftCorresp As List(Of Correspondance)
    Protected _lRightCorresp As List(Of Correspondance)
    Protected _typeJointure As typeJointure
    Protected _aEteTraitee As Boolean

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend Sub New(ByVal leftTraitement As Traitement, _
                             ByVal lLeftCorresp As List(Of Correspondance), _
                             ByVal rightTraitement As Traitement, _
                             ByVal lRightCorresp As List(Of Correspondance), _
                             ByVal typeJointure As typeJointure)
        _leftTraitement = leftTraitement
        _lLeftCorresp = lLeftCorresp
        _lRightCorresp = lRightCorresp
        _rightTraitement = rightTraitement
        _typeJointure = typeJointure
        _aEteTraitee = False
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend Function genereFROM() As String
        Dim result As String = ""
        result = result & _leftTraitement.nomTableDansBDD & " AS " & _leftTraitement.nom & " left join " & _rightTraitement.nomTableDansBDD & " AS " & _rightTraitement.nom
        Return result
    End Function
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend Function genereON() As String
        Dim result As String = ""
        For i As Integer = 0 To _lLeftCorresp.Count - 1

            Dim a As String = _leftTraitement.nomTableDansBDD
            Dim b As String = _lLeftCorresp(i).chOutil.Nom
            Dim c As String = _rightTraitement.nomTableDansBDD
            Dim d As String = _lRightCorresp(i).chOutil.Nom

            result = result & _leftTraitement.tempNom & _
                             "." & _lLeftCorresp(i).chOutil.Nom & _
                             "=" & _rightTraitement.tempNom & _
                             "." & _lRightCorresp(i).chOutil.Nom & " AND "
        Next
        Return Microsoft.VisualBasic.Left(result, Len(result) - 5)
    End Function

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend Property aEteTraitee() As Boolean
        Get
            Return _aEteTraitee
        End Get
        Set(ByVal value As Boolean)
            _aEteTraitee = value
        End Set
    End Property
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend ReadOnly Property leftTraitement() As Traitement
        Get
            Return _leftTraitement
        End Get
    End Property
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend ReadOnly Property rightTraitement() As Traitement
        Get
            Return _rightTraitement
        End Get
    End Property
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend ReadOnly Property leftCorresp() As List(Of Correspondance)
        Get
            Return _lLeftCorresp
        End Get
    End Property
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend ReadOnly Property rightCorresp() As List(Of Correspondance)
        Get
            Return _lRightCorresp
        End Get
    End Property
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Friend ReadOnly Property typeJointure() As typeJointure
        Get
            Return _typeJointure
        End Get
    End Property

End Class

